from json import loads

from requests import get

# {% tag 替换为 {% hashtag
# {% ablock 替换为 {% box
# {% endablock 替换为 {% endbox

url = "https://api.github.com/repos/xaoxuu/hexo-theme-stellar/releases?per_page=30"

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.5359.95 '
                  'Safari/537.36'
}

resp = get(url, headers=headers)
resp = resp.text.encode('utf-8').decode('utf-8')
resp = loads(resp)

with open("update_log.txt", "w", encoding='utf-8') as file:
    for update_log in resp:
        file.write(update_log["tag_name"])
        file.write("\n")
        file.write(update_log["body"])
        file.write("\n\n")
        file.write("=======分割线=========")
        file.write("\n\n")
        if update_log["tag_name"] == '1.19.0':
            break
